using System;
using System.Globalization;
using NUnit.Framework;

namespace ValidationFramework.Tests
{
    [TestFixture]
	public class NumberConversionRuleAttributeTest
    {


        [Test]
        public void CheckValues()
		{
        	const TypeCode expectedTypeCode = TypeCode.Decimal;
			const NumberStyles expectedNumberStyles = NumberStyles.Integer;
			var ruleAttribute = new NumberConversionRuleAttribute(expectedTypeCode);
			Assert.AreEqual(expectedTypeCode, ruleAttribute.TypeCode);

			var propertyRule = (NumberConversionRule)ruleAttribute.CreateRule(new MockPropertyDescriptor<string>("foo"));
			var parameterRule = (NumberConversionRule)ruleAttribute.CreateRule(new MockParameterDescriptor<string>("foo"));

			Assert.AreEqual(expectedTypeCode, propertyRule.TypeCode);
			Assert.AreEqual(expectedTypeCode, parameterRule.TypeCode);

            ruleAttribute.NumberStyles = expectedNumberStyles;
			Assert.AreEqual(expectedNumberStyles, ruleAttribute.NumberStyles);

			propertyRule = (NumberConversionRule)ruleAttribute.CreateRule(new MockPropertyDescriptor<string>("foo"));
			parameterRule = (NumberConversionRule)ruleAttribute.CreateRule(new MockParameterDescriptor<string>("foo"));

			Assert.AreEqual(expectedNumberStyles, propertyRule.NumberStyles);
			Assert.AreEqual(expectedNumberStyles, parameterRule.NumberStyles);


        }


        [Test]
        public void CallAttributeTester()
        {
			AttributeTester.CheckDefaultValues<string>(new NumberConversionRuleAttribute(TypeCode.Decimal), true, true);
			AttributeTester.CheckNonDefaultValues<string>(new NumberConversionRuleAttribute(TypeCode.Decimal), true, true);
        }

    }
}